﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="CheckBoxFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border>
                        <Rectangle 
                            Margin="15,0,0,0"
                            StrokeThickness="1"
                            Stroke="#60000000"
                            StrokeDashArray="1 2"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="CheckBox">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="FocusVisualStyle"    Value="{StaticResource CheckBoxFocusVisual}"/>

        <Setter Property="Margin" Value="2,4,2,4"/>
        <Setter Property="VerticalAlignment"  Value="Center"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CheckBox">
                    <BulletDecorator Background="Transparent" Cursor="Hand" VerticalAlignment="Center">
                        <BulletDecorator.Bullet>
                            <Border x:Name="Border"                                      
                                    Width="13" 
                                    Height="13" Margin="3"
                                    CornerRadius="2" 
                                    VerticalAlignment="Center"                                    
                                    Background="Transparent"
                                    BorderThickness="1"
                                    BorderBrush="{StaticResource TextBoxBorderBrush}">
                                <Border
                                    CornerRadius="2"
                                    Width="9" Height="9" 
                                    x:Name="CheckMark"
                                    Background="{StaticResource LabelBrush}"
                                    SnapsToDevicePixels="True"/>
                            </Border>
                        </BulletDecorator.Bullet>
                        <ContentPresenter
                            Cursor="Hand"
                            Margin="4,0,0,0"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Left"
                            RecognizesAccessKey="True">
                            <ContentPresenter.Resources>
                                <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource LabelTextBlock}"/>                                    
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                    </BulletDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="false">
                            <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="{x:Null}">
                            <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource MouseOverBackgroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="Border" Property="Background" Value="Gray" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="Gray" />
                            <Setter Property="Foreground" Value="Gray"/>
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="RadioButton">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="FocusVisualStyle"    Value="{StaticResource CheckBoxFocusVisual}"/>

        <Setter Property="Margin" Value="2,4,2,4"/>
        <Setter Property="VerticalAlignment"  Value="Center"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RadioButton">
                    <BulletDecorator Background="Transparent" Cursor="Hand" VerticalAlignment="Center">
                        <BulletDecorator.Bullet>
                            <Border x:Name="Border"                                      
                                    Width="13" 
                                    Height="13" 
                                    CornerRadius="2" 
                                    VerticalAlignment="Center"                                    
                                    Background="Transparent"
                                    BorderThickness="1"
                                    BorderBrush="{StaticResource TextBoxBorderBrush}">
                                <Border
                                    CornerRadius="2"
                                    Width="9" Height="9" 
                                    x:Name="CheckMark"
                                    Background="{StaticResource LabelBrush}"
                                    SnapsToDevicePixels="True"/>
                            </Border>
                        </BulletDecorator.Bullet>
                        <ContentPresenter
                            Cursor="Hand"
                            Margin="4,0,0,0"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Left"
                            RecognizesAccessKey="True">
                            <ContentPresenter.Resources>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="Foreground" Value="{StaticResource LabelBrush}"/>
                                    <Setter Property="FontSize" Value="{StaticResource NormalFontSize}"/>
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                    </BulletDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="false">
                            <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="{x:Null}">
                            <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource MouseOverBackgroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="Border" Property="Background" Value="Gray" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="Gray" />
                            <Setter Property="Foreground" Value="Gray"/>
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>